#!/bin/bash
#set -x
wid=`xdotool search --name "movetest*"` || exit 1
xdotool mousemove --window $wid 0 0
position1=`xdotool getmouselocation --shell`
pos_x=`echo "$position1" | awk -F= '$1 ~ /X/{print $2}'`
pos_x=$[ $pos_x + 80 ]
pos_y=`echo "$position1" | awk -F= '$1 ~ /Y/{print $2}'`
pos_y=$[ $pos_y - 5 ]
xdotool mousemove $pos_x $pos_y
xdotool mousedown 1
idx=0 
while true; do
    idx=$[ $idx + 10 ]
    rev=$[ $idx % 1000 - 500 ]
    rev=${rev#-}
    rev=$[ 500 - $rev ]
    pos_xt=$[ $pos_x + $rev ] 
    xdotool mousemove $pos_xt $pos_y
    xdotool sleep 0.01
done
